# Contributor: Anjandev Momi <anjan@momi.ca>
# Maintainer: Anjandev Momi <anjan@momi.ca>
pkgname=river
pkgver=0.1.3
pkgrel=1
pkgdesc="Dynamic Tiling Wayland Compositor"
url="https://github.com/riverwm/river"
arch="x86_64 aarch64" # limited by zig aport
license="GPL-3.0-or-later"
makedepends="libevdev-dev libxkbcommon-dev pixman-dev scdoc wayland-dev
	wayland-protocols wlroots-dev zig
	"
depends="seatd"
subpackages="
	$pkgname-doc
	$pkgname-bash-completion
	$pkgname-fish-completion
	$pkgname-zsh-completion
	"
source="https://github.com/riverwm/river/releases/download/v$pkgver/river-$pkgver.tar.gz"

# We may want other than "baseline" for other targets, when enabled by zig
case "$CARCH" in
	aarch64|x86_64) cputarget=baseline ;;
esac

build() {
	# This installs it to $builddir/out
	DESTDIR="$builddir/out" zig build -Drelease-safe --prefix /usr install \
		${cputarget:+-Dcpu="$cputarget"}
}

check() {
	zig build test
}

package() {
	mkdir -p "$pkgdir"
	cp -r out/* "$pkgdir"

	# Fix location of pkgconfig files, must be fixed upstream
	mkdir -p "$pkgdir"/usr/lib
	mv "$pkgdir"/usr/share/pkgconfig "$pkgdir"/usr/lib

	# Install example configuration
	install -Dm0644 example/init -t "$pkgdir"/usr/share/doc/river/examples

	# Fix location of fish completion
	mkdir -p "$pkgdir"/usr/share/fish/completions/
	mv "$pkgdir"/usr/share/fish/vendor_completions.d/*.fish \
		"$pkgdir"/usr/share/fish/completions/
	rm -rf "$pkgdir"/usr/share/fish/vendor_completions.d
}

sha512sums="
8dd8ad8b17fb1d9d65e413aaaa456fda89f8bedd580db247c3ffa8235a67712394182b3498a9c6eb3707cfc571c398bb5086cf09810e4a9438d26ea19f41f5a9  river-0.1.3.tar.gz
"
